package com.ysu.his.admin.controller;


import com.github.pagehelper.PageInfo;
import com.ysu.his.admin.service.ICDCatalogService;
import com.ysu.his.dto.ICDCatalogDto;
import com.ysu.his.entity.diagnosis.IcdCatalog;
import com.ysu.his.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/admin/icdCatalog")
public class ICDCatalogController
{
    @Autowired
    private ICDCatalogService icdCatalogService;

    @GetMapping(value = "/getCatalogByPage/{page}/{limit}")
    public Result getCatalogByPage(@PathVariable("page") Integer page,
                                   @PathVariable("limit") Integer limit,
                                   ICDCatalogDto icdCatalogDto)
    {
        PageInfo<IcdCatalog> pageInfo = icdCatalogService.getCatalogByPage(page,limit,icdCatalogDto);
        return Result.ok(pageInfo);
    }

    @PostMapping(value = "/addICDCatalog")
    public Result addICDCatalog(@RequestBody IcdCatalog icdCatalog)
    {
        icdCatalogService.addICDCatalog(icdCatalog);
        return Result.ok(null);
    }

    @PutMapping(value = "/updateICDCataLog")
    public Result updateICDCataLog(@RequestBody IcdCatalog icdCatalog)
    {
        icdCatalogService.updateICDCatalog(icdCatalog);
        return Result.ok(null);
    }

    @GetMapping(value = "/startOrStop/{id}/{status}")
    public Result startOrStop(@PathVariable("id")Long id,
                              @PathVariable("status") Integer status)
    {
        icdCatalogService.startOrStop(id,status);
        return Result.ok(null);
    }
}
